package com.sz.jinzheng.controller;

import com.sz.jinzheng.cilent.UserCilent;
import com.sz.jinzheng.model.PageBean;
import com.sz.jinzheng.model.Result;
import com.sz.jinzheng.model.StaffExmination;
import com.sz.jinzheng.service.StaffExaminationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/inspector")
public class StaffExaminationController {
    @Autowired
    private StaffExaminationService staffExaminationService;

    @Autowired
    private UserCilent userCilent;
    /**
     * 执行审查的方法
     *
     * @param staffExmination
     * @return
     */
    @RequestMapping("/updateStaffExmination")
    public Result updateStaffExmination(@RequestBody StaffExmination staffExmination) {
        log.info("staffExmination.toString()=" + staffExmination.toString());
        int i = staffExaminationService.updateStaffExmination(staffExmination);
        if (i > 0) {
            return new Result(200, "成功", null);
        }
        return new Result(409, "失败", null);
    }

    @RequestMapping("/getMyCompleteStaffExmination")
    public Result getMyCompleteStaffExmination(String token, int index, int size) {
        log.info("token"+token);
        Integer staffMemberId = userCilent.getUid(token);
        PageBean<StaffExmination> exmination = staffExaminationService.getMyCompleteStaffExmination(staffMemberId, index, size);
        return new Result(200,"成功",exmination);
    }
    @RequestMapping("/getMyCompletingStaffExmination")
    public Result getMyCompletingStaffExmination(String token, int index, int size) {
        log.info("token"+token);
        Integer staffMemberId = userCilent.getUid(token);
        PageBean<StaffExmination> exmination = staffExaminationService.getMyCompletingStaffExmination(staffMemberId, index, size);
        return new Result(200,"成功",exmination);
    }
}